package com.ztsoft.user.controller.project;

import com.ztsoft.user.pojo.entity.project.Agency;
import com.ztsoft.user.service.project.AgencyService;
import com.ztsoft.user.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@CrossOrigin("*")
@RestController
@RequestMapping("/agency")
@Api(tags = "代理机构控制层")
public class AgencyController {

    @Resource
    private AgencyService agencyService;

    @PutMapping("/updateAgency")
    @ApiOperation(value = "修改代理机构", notes = "修改代理机构")
    public Result<Object> updateAgency(@RequestBody Agency agency) {
        return agencyService.updateAgency(agency);
    }

    @PostMapping("/addAgency")
    @ApiOperation(value = "添加代理机构", notes = "添加代理机构")
    public Result<Object> addAgency(@RequestBody Agency agency) {
        return agencyService.addAgency(agency);
    }

    @DeleteMapping("/deleteAgency/{id}")
    @ApiOperation(value = "删除代理机构", notes = "删除代理机构")
    public Result<Object> deleteAgency(@PathVariable("id") String id) {
        return agencyService.deleteAgency(id);
    }

    @GetMapping("/getAgencyMeta")
    @ApiOperation(value = "获取所有代理机构主键及名称", notes = "获取所有代理机构主键及名称")
    public Result<Object> getAgencyMeta() {
        return agencyService.getAgencyMeta();
    }

}